package uk.co.iceroad.twu.m1;

import org.junit.Before;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.Assert.*;

public class FizzBuzzTest {


    private ByteArrayOutputStream testSysOut;

    @Before
    public void before() {
        //Modify Sys Out so we can check the printed output is as expected
        this.testSysOut = new ByteArrayOutputStream();
        System.setOut(new PrintStream(testSysOut));
    }

    @Test
    public void testFizzAndBuzz(){
        FizzBuzz fizzBuzz = new FizzBuzz();
        fizzBuzz.print(15);
        assertEquals("FizzBuzz\n", testSysOut.toString());
    }

    @Test
      public void testFizz(){
        FizzBuzz fizzBuzz = new FizzBuzz();
        fizzBuzz.print(3);
        assertEquals("Fizz\n", testSysOut.toString());
    }

    @Test
    public void testBuzz(){
        FizzBuzz fizzBuzz = new FizzBuzz();
        fizzBuzz.print(5);
        assertEquals("Buzz\n", testSysOut.toString());
    }

    @Test
    public void testnoFizzBuzz(){
        FizzBuzz fizzBuzz = new FizzBuzz();
        fizzBuzz.print(8);
        assertEquals("8\n", testSysOut.toString());
    }
}
